import React, {Component} from 'react';
import {View} from  'react-native';
import TopView from  './Brand';
import Activity from './Activity';
import ClassView from './ClassificationView';
import BottomCommonCell from './BottomCommonCell';
import ShopCenter from './ShopCenter';
import Banner from './MyBanner';
import MyWebView from './MyWebView';
export default class HomeHeadView extends Component{
    render(){
        return(
            <View style={{backgroundColor: '#e8e8e8'}}>
                <Banner popToHomeView={(url,title)=>this.openWebView(url,title)}/>
                <ClassView popToHomeView={(componentName,param)=>this.popToTopView(componentName,param)}/>
                <TopView/>
                <Activity popTopHome={(url,title)=>{this.openWebView(url,title)}}/>
                <ShopCenter popToHomeView={(url,title)=>this.openWebView(url,title)}/>
                <View style={{marginTop:15}}>
                    <BottomCommonCell leftIcon="heartbeat" leftTitle='猜你喜欢'/>
                </View>
            </View>
        )
    }

    openWebView(url,title) {
        const { navigate } = this.props.navigator;
        let param={url:HomeHeadView.dealWithUrl(url),title:title};
        navigate('MyWebView',param)
    }

    popToTopView(componentName,param) {
        this.props.popTopHome(componentName,param);
    }

    static dealWithUrl(url) {
        return url.replace('imeituan://www.meituan.com/web/?url=', '');
    }
}
HomeHeadView.propTypes={
    navigator:React.PropTypes.object,
    popTopHome:React.PropTypes.func
};
HomeHeadView.defaultProps={
    navigator:null,
    popTopHome:null
};